package com.coding.kan_yi_dao.service.impl;

import com.coding.kan_yi_dao.common.Result;
import com.coding.kan_yi_dao.entity.GoodsLike;
import com.coding.kan_yi_dao.entity.GoodsNew;
import com.coding.kan_yi_dao.mapper.GoodsLikeMapper;
import com.coding.kan_yi_dao.service.IGoodsLikeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 砍一刀，不买就砍你一刀
 * @since 2023-09-20
 */
@Service
public class GoodsLikeServiceImpl extends ServiceImpl<GoodsLikeMapper, GoodsLike> implements IGoodsLikeService {
    @Resource
    GoodsLikeMapper goodsLikeMapper;

    //查询
    @Override
    public Result go_select(GoodsLike goodsLike) {
       Integer b= goodsLike.getGoodsLikeId();
        return Result.ok(goodsLikeMapper.go_selectall(b));
    }

    //修改
    @Override
    public Result go_update(GoodsLike goodsLike) {
        return Result.ok(baseMapper.updateById(goodsLike));
    }

    //添加
    @Override
    public Result go_insert(GoodsLike goodsLike) {
        return Result.ok(baseMapper.insert(goodsLike));
    }

    //删除
    @Override
    public Result go_delete(List<Integer> ids) {
        List<GoodsLike> goodsLikes = new ArrayList<>();
        for (int i = 0; i < ids.size(); i++) {
            GoodsLike goodsLike = new GoodsLike();
            goodsLike.setGoodsLikeId(ids.get(i));
            goodsLike.setGoodsLikeDelete(0);
            goodsLikes.add(goodsLike);
        }
        return Result.ok(updateBatchById(goodsLikes));
    }


}
